package com.example.distributed_lock.lock;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @author :ld
 * @date :2021/7/9
 */
@Component
public class RedisLockFactory {
    private final StringRedisTemplate redisTemplate;

    public RedisLockFactory(StringRedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    public SimpleRedisLock getSimpleRedisTemplate(String key){
        return new SimpleRedisLock(key,redisTemplate);
    }

    public ReentrantRedisLock getReentrantLock(String key){
        return new ReentrantRedisLock(key,redisTemplate);
    }
}
